//
//  WelcomeViewController.m
//  Matador
//
//  Created by leaf on 15/10/4.
//  Copyright © 2015年 MicroGolds. All rights reserved.
//

#import "WelcomeViewController.h"

#import "LoginViewController.h"
#import "RegisteViewController.h"

@interface WelcomeViewController ()

@end

@implementation WelcomeViewController

#pragma mark - Inner Methods
- (void)loginBtnPressed {
    LoginViewController *vc = [[LoginViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)registBtnPressed {
    RegisteViewController *vc = [[RegisteViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark - View Control
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UIImageView *bg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    bg.image = [UIImage imageNamed:@"welcome_bg"];
    [self.view addSubview:bg];
        
    UIImageView *logo = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, MTDFloat(851), MTDFloat(605))];
    logo.centerX = ScreenWidth * 0.5f;
    logo.centerY = MTDFloat(600);
    logo.image = [UIImage imageNamed:@"welcome_logo"];
    [self.view addSubview:logo];
    
    NSString *text = @"一站式的金融社区";
    UIFont *font = [UIFont systemFontOfSize:20];
    CGSize size = [text mtdSizeWithFont:font];
    
    UILabel *slogan = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
    slogan.centerX = logo.centerX;
    slogan.top = logo.bottom + MTDFloat(240);
    slogan.backgroundColor = [UIColor clearColor];
    slogan.textColor = [UIColor whiteColor];
    slogan.font = font;
    slogan.text = text;
    [self.view addSubview:slogan];
    
    UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    loginBtn.frame = CGRectMake(0, 0, MTDFloat(554), MTDFloat(157));
    loginBtn.left = MTDFloat(53);
    loginBtn.top = slogan.bottom + MTDFloat(200);
    [loginBtn.titleLabel setFont:font];
    [loginBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [loginBtn setTitle:@"立即登录" forState:UIControlStateNormal];
    [loginBtn setBackgroundImage:[UIImage imageNamed:@"welcome_login_btn"] forState:UIControlStateNormal];
    [loginBtn addTarget:self action:@selector(loginBtnPressed) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:loginBtn];
    
    UIButton *registeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    registeBtn.frame = CGRectMake(0, 0, MTDFloat(554), MTDFloat(157));
    registeBtn.right = ScreenWidth - MTDFloat(53);
    registeBtn.top = loginBtn.top;
    [registeBtn.titleLabel setFont:font];
    [registeBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [registeBtn setTitle:@"注册" forState:UIControlStateNormal];
    [registeBtn setBackgroundImage:[UIImage imageNamed:@"welcome_registe_btn"] forState:UIControlStateNormal];
    [registeBtn addTarget:self action:@selector(registBtnPressed) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:registeBtn];
    
    UIButton *guestBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    guestBtn.frame = CGRectMake(0, 0, MTDFloat(1136), MTDFloat(157));
    guestBtn.left = MTDFloat(53);
    guestBtn.top = loginBtn.bottom + MTDFloat(36);
    [guestBtn.titleLabel setFont:font];
    [guestBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [guestBtn setTitle:@"随便逛逛" forState:UIControlStateNormal];
    [guestBtn setBackgroundImage:[UIImage imageNamed:@"welcome_guest_btn"] forState:UIControlStateNormal];
    [self.view addSubview:guestBtn];
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
